package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.LineBaseBigType;
import com.sailfish.springbootdemo.service.db1.LineBaseBigTypeService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/lineBaseBigType")
public class LineBaseBigTypeController {

    @Autowired
    private LineBaseBigTypeService lineBaseBigTypeService;

    @PostMapping("/getAllLineBaseBigType")
    public Result getAllLineBaseBigType(String searchValue) {
        try {
            return ResultUtil.success(lineBaseBigTypeService.getAllLineBaseBigType(searchValue));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/addOrUpdateLineBaseBigType")
    public Result addOrUpdateLineBaseBigType(LineBaseBigType lineBaseBigType, String mode) {
        return lineBaseBigTypeService.addOrUpdateLineBaseBigType(lineBaseBigType, mode);
    }

    @PostMapping("/deleteLineBaseBigType")
    public Result deleteLineBaseBigType(Integer lineBaseBigTypeId) {
        return lineBaseBigTypeService.deleteLineBaseBigType(lineBaseBigTypeId);
    }

    @PostMapping("/getAllLineBaseBigTypeAndSmallAndRule")
    public Result getAllLineBaseBigTypeAndSmallAndRule() {
        try {
            return ResultUtil.success(lineBaseBigTypeService.getAllLineBaseBigTypeAndSmallAndRule());
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }
}
